﻿@using OpenMms.Domain.Models
@model UserInforMations
@{
    ViewData["Title"] = "Index";
    Layout = "~/Areas/User/Views/_UserLayout.cshtml";
}


<!-- APP MAIN ==========-->
<main id="app-main" class="app-main">
    <div class="wrap">
        <section class="app-content">
            <div class="widget">
                <header class="widget-header title1">
                    <h4 class="widget-title">修改个人资料</h4>
                </header><!-- .widget-header -->
                <hr class="widget-separator">

                <div class="widget-body">
                    <form id="form1" method="post" class="form-horizontal">
                        <div class="form-group">
                            <label for="#" class="col-sm-2 control-label">真实姓名</label>
                            <div class="col-sm-5">
                                <input class="form-control" type="text" required pattern="^[\u4E00-\u9FA5]{2,4}$"
                                       title="姓名只能由汉字组成" name="UserName" id="UserName" value="@Model.UserName">
                            </div>
                        </div><!-- .form-group -->

                        <div class="form-group">
                            <label for="#" class="col-sm-2 control-label">身份证号</label>
                            <div class="col-sm-5">
                                <input class="form-control" type="text" name="IdNum" id="IdNumber" value="@Model.IdNumber"
                                       required pattern="/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/" title="身份证格式不正确">
                            </div>
                        </div><!-- .form-group -->

                        <div class="form-group">
                            <label for="#" class="col-sm-2 control-label">手机号</label>
                            <div class="col-sm-5">
                                <input class="form-control" type="text" name="UserPhone" id="Phone"
                                       required pattern="^1[34578]\d{9}$" title="手机号格式不正确" value="@Model.Phone">
                            </div>
                        </div><!-- .form-group -->

                        <div class="form-group">
                            <label for="select2-demo-1" class="col-sm-2 control-label">银行名称</label>
                            <div class="col-sm-5">
                                <input class="form-control" type="text" name="BankName" id="BankName" required value="@Model.BankName">
                            </div><!-- END column -->
                        </div><!-- .form-group -->

                        <div class="form-group">
                            <label for="#" class="col-sm-2 control-label">银行账号</label>
                            <div class="col-sm-5">
                                <input class="form-control" type="text" id="BankCode" name="BankCode" required value="@Model.BankCode">
                            </div>
                        </div><!-- .form-group -->

                        <div class="form-group">
                            <label for="#" class="col-sm-2 control-label">持卡人姓名</label>
                            <div class="col-sm-5">
                                <input class="form-control" type="text" id="CardHolder" name="CardHolder" required value="@Model.CardHolder">
                            </div>
                        </div><!-- .form-group -->

                        <div class="form-group">
                            <label for="#" class="col-sm-2 control-label">二级密码</label>
                            <div class="col-sm-5">
                                <input class="form-control" id="UserSecondPassWord" name="UserSecondPassWord" type="password" required placeholder="请输入二级密码">
                            </div>
                        </div><!-- .form-group -->
                        <div class="form-group">
                            <div class="col-sm-7 text-center">
                                @Html.AntiForgeryToken()
                                <button type="submit" id="btn" class="btn btn-info">确认修改</button>
                            </div>
                        </div>
                    </form>
                </div><!-- .widget-body -->
            </div><!-- .widget -->
        </section><!-- #dash-content -->
    </div><!-- .wrap -->
    <!-- APP FOOTER -->
    <div class="wrap p-t-0">
        <footer class="app-footer">
            <div class="clearfix">
                <div class="copyright text-center w100">@OpenMms.Common.Url.NameConfig.companyName &copy;</div>
            </div>
        </footer>
    </div>
    <!-- /#app-footer -->
</main>
<!--========== END app main -->
<script src="~/DirectSellJs/jquery.unobtrusive-ajax.min.js"></script>
<script type="text/javascript">
    $('#form1').on('submit', function () {
        layer.confirm('确定要修改用户资料？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            formPost();
        }, function () {
            layer.close();
        });
        event.preventDefault() //阻止form表单默认提交
    })
    function formPost() {
        //加载层
        var index = layer.load(1, {
            shade: [0.1, '#fff']
        });
        $.ajax({
            type: "post",
            url: "/User/ModifyInfo/Modify",
            data: $('#form1').serialize()
        }).success(function (message) {
            if (message.code != 200) {
                layer.msg(message.message, { icon: 2 });
            }
            else {
                layer.msg(message.message, { icon: 1 });
            }
        }).fail(function (err) {
            layer.msg('系统错误,请稍后重试', { icon: 2 });
        })
        layer.close(index)//关闭加载层
    }
</script>

